﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KAImage.Config;
using System.Drawing;

namespace KAImage.AlgorAction
{
    public class MegreAction : IDisposable
    {
        private ImageMegreOption _option = new ImageMegreOption();
      
        private bool _enabled = false;
        public bool Enabled
        {
            private set
            {
                _enabled = value;
            }
            get
            {
                return _enabled;
            }
        }

        private int _callIndex = 4;
        public int CallIndex
        {
            private set
            {
                _callIndex = value;
            }
            get
            {
                return _callIndex;
            }
        }

        public MegreAction()
        {
            _option = KAConfigs.Merge;
            _enabled = KAConfigs.AlgorApplying.Megre;
        }

        public Bitmap DoAction(System.Drawing.Bitmap source)
        {
            Bitmap destImage = null;
            ImageMegreMode mode = _option.MegreMode;
            switch (mode)
            {
                case ImageMegreMode.Screen:
                    destImage = ImgMerging.ScreenForGrayAndOrig(source, _option.OpacityScreen);
                    break;
                case ImageMegreMode.Multiply:
                    destImage = ImgMerging.MultiplyForOrigAndOrig(source, _option.OpacityMultiply);
                    break;
                case ImageMegreMode.Both:
                    destImage = ImgMerging.OnMultipleMixing(source, _option.OpacityScreen, _option.OpacityMultiply);
                    break;
                default:
                    break;
            }
            return destImage;
        }

        public void Dispose()
        {
            
        }
    }
}
